<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>安全库存配置单复核</title>

    <style>
        table tr th,td{
            border: 1px solid black;
            text-align: center;
        }
        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
    </style>

    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/admin.css">
    <link rel="stylesheet" href="../css/bootstrap.css">

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/bootstrap-table1.15.3.js"></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
</head>

<script>

    function initReviewOpinion() {
        /*JunM*/
        $('#reviewOpinionTableInfo').bootstrapTable(
            {
                //请求方式
                method:'post',
                contentType:'application/json',
                url:'/sCell/querySearchProductIdAll.action',
                //设置交替样式
                striped:true,
                //初始显示页号
                pageNumber:1,
                //是否显示分页
                pagination:true,
                //是否设置服务端分页还是客户端分页
                sidePagination:'server',
                //页面大小
                pageSize:3,
                //分页列表
                pageList:[1,3,5,6,10],
                //上传到到服务端的参数
                queryParams:function (pares) {
                    return{
                        //计算页号（当前页）
                        pageNum:(pares.offset/pares.limit)+1,
                        //计算页大小
                        pageSize:pares.limit,
                    }
                },
                //第一列名
                columns:[
                    {title:"配置单编号",field:"storeId",align:"center"},
                    {title:"产品编号",field:"productId",align:"center"},
                    {title:"产品名称",field:"productName",align:"center"},
                    {title:"用途类型",field:"dFile.TYPE",align:"center",formatter:function (value,row,index) {
                            if(value == 'Y001-1'){
                                return '商品'
                            }else if(value == 'Y001-2'){
                                return '物料'
                            }
                        }},
                    {title:"I级分类",field:"firstKindName",align:"center"},
                    {title:"II级分类",field:"secondKindName",align:"center"},
                    {title:"III级分类",field:"thirdKindName",align:"center"},
                    {title:"登记时间",field:"registerTime",align:"center"},
                    {title:"复核",field:"checkTag",align:"center",formatter:function (value,row,index) {
                            return "<a href='#' onclick='updateSCell("+JSON.stringify(row)+")' data-toggle='modal' data-target='#reviewOpinionModal'>复核</a>"
                        } }
                ]
            })

    }

    $(function () {
        initReviewOpinion();

        //往SCell中添加数据，且修改 CHECK_TAG 审核标志 T001-0 未通过 T001-1 通过
        $('#updateSCellBtn').click(function () {

            let formValues = $('#addSCellFormId').serialize();
            // alert(formValues);
            let splitId = $('#kindId').text().split('-');
            // alert(split[0])
            formValues=formValues+'&firstKindId='+splitId[0]+'&secondKindId='+splitId[1]+'&thirdKindId='+splitId[2];
            // alert(formValues)
            let splitName = $('#kindName').text().split('-');
            formValues=formValues+'&firstKindName='+splitName[0]+'&secondKindName='+splitName[1]+'&thirdKindName='+splitName[2];
            $.ajax({
                type:'post',
                url:'/sCell/updateSCellByProductId',
                // flag为标识符 1为复核， 0为变更
                data:formValues+'&flag='+1,
                success:function () {
                    alert('制定成功...');
                    $('#reviewOpinionModal').modal('hide');
                    $('#reviewOpinionTableInfo').bootstrapTable('refresh');
                },
                error:function (data) {
                    alert(data+"制定失败...")
                }
            })
        });
    })

    //把列表中的值，拿到模态框中
    function updateSCell(rows) {

        $('#tbodyId').empty();
        $(":input","#addSCellFormId")
            .not(":button",":reset","hidden","submit")
            .val("")
            .removeAttr("checked")
            .removeAttr("selected");

        $('#storeId').val(rows.storeId);
        $('#productName').val(rows.productName);
        $('#productId').val(rows.productId);
        $('#minAmount').val(rows.minAmount);
        $('#maxAmount').val(rows.maxAmount);
        $('#checker').val(rows.register);
        $('#config').val(rows.config);
        //表格
        $('#tbodyId').empty();
        var trObj=$('#tbodyId').append($('<tr>'));
        trObj.append($('<td>').text(1));
        trObj.append($('<td>').text("成品库"));
        trObj.append($('<td id="kindId">').text(rows.firstKindId+"-"+rows.secondKindId+"-"+rows.thirdKindId));
        trObj.append($('<td id="kindName">').text(rows.firstKindName+"-"+rows.secondKindName+"-"+rows.thirdKindName));
        trObj.append($('<td>').html('<input value='+rows.maxCapacityAmount+' name="maxCapacityAmount" id="maxCapacityAmount" style="border: none;width: 60px;">'));

        var today=new Date();
        let year = today.getFullYear();
        let month = today.getMonth();
        let date = today.getDate();
        let hours = today.getHours();
        let minutes = today.getMinutes();
        let seconds = today.getSeconds();
        today=year+"-"+(month+1)+"-"+date+" "+hours+":"+minutes+":"+seconds;
        $('#checkTime').val(today);
    }

</script>


<body bgcolor="#f5f5f5">
<div class="container-fluid">
    <div style="width: 100%;margin: 0px;padding: 0px">
        <table id="reviewOpinionTableInfo" class="table table-bordered table-hover table-striped table-condensed">

        </table>
    </div>
</div>

<!--模态框-->
<!--modal fade-->
<div class="modal  fade" id="reviewOpinionModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 90%">
        <div class="modal-content" style="border: 1px solid black;">
            <div class="modal-header">
                <div class="container">
                    <div class="row">
                        <div class="col-7" style="text-align: right">
                            <h5 class="modal-title" id="info" >
                                安全库存配置单
                            </h5>
                        </div>
                        <div class="col-4" style="position: absolute;right: 30px">
                        </div>
                    </div>
                </div>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right: 0px">

                </button>


            </div>
            <div class="modal-body">
                <form id="addSCellFormId">
                    <div class="container">
                        <div class="row">
                            <div class="col-2" style="text-align:right">
                                产品名称：
                            </div>
                            <div class="col-4">
                                <!--                                    <span id="productName"></span>-->
                                <input style="border: none;background-color: white;" name="productName" id="productName">
                            </div>
                            <div class="col-2" style="text-align:right">
                                产品编号：
                            </div>
                            <div class="col-4">
                                <!--                                    <span id="productId" ></span>-->
                                <input style="border: none;background-color: white;" name="productId" id="productId">
                            </div>
                        </div>
                    </div>
                    <br>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-2" style="text-align: right">
                                <span>库存报警下限数：</span>
                            </div>
                            <div class="col-4">
                                <input class="form-control form-small" style="width: 300px" placeholder="库存报警下限数"  name="minAmount" id="minAmount"><br>
                            </div>
                            <div class="col-2" style="text-align: right">
                                <span>库存报警上限数：</span>
                            </div>
                            <div class="col-4">
                                <input class="form-control form-small" style="width: 300px" placeholder="库存报警上限数"  name="maxAmount" id="maxAmount"><br>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-2" style="text-align: right">
                                <span>配置单编号：</span>
                            </div>
                            <div class="col-4">
                                <input style="width: 300px;border: none;background-color: white;" name="storeId" id="storeId"><br>
                            </div>
                            <div class="col-2" style="text-align: right">
                                <span>设计人：</span>
                            </div>
                            <div class="col-4">
                                <input class="form-control form-small" style="width: 300px" placeholder="设计人"  name="designer" id="designer"><br>
                            </div>
                        </div>
                    </div>
                    <table width="80%" style="margin-top: 20px;" class="table table-sm">
                        <thead  style="background-color: #b3d7ff;">
                        <tr>
                            <th>序号</th>
                            <th>库存名称</th>
                            <th>存储地址编号</th>
                            <th>存储地址名称</th>
                            <th>最大存储量</th>
                        </tr>
                        </thead>
                        <tbody id="tbodyId">
                        <!--<td>1</td>
                        <td>成品库</td>
                        <td>01-01-01</td>
                        <td>电子-计算机-服务器</td>
                        <td><input style="border: none;width: 60px;"></td>
                        <td><input style="border: none;width: 60px;"></td>
                        <td><input style="border: none;width: 60px;"></td>-->
                        </tbody>
                    </table><br>
                    <div class="container">
                        <div class="row">
                            <div class="col-2" style="text-align:right">
                                复核人：
                            </div>
                            <div class="col-4">
                                <input class="form-control" style="width: 200px;" placeholder="复核人" name="checker" id="checker">
                            </div>
                            <div class="col-2" style="text-align:right">
                                复核时间：
                            </div>
                            <div class="col-4">
                                <input style="width: 200px;border: none;background-color: white;" placeholder="复核时间" name="checkTime" id="checkTime">
                                <!--                                    <span id="checkTime"></span>-->
                            </div>
                        </div>
                    </div><br>
                    <span style="margin-left: 55px">配置要求：</span>
                    <textarea id="config" name="config" style="width: 550px;margin-left: 150px" class="form-control">

                        </textarea>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" id="updateSCellBtn">
                    复核通过
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
</html>